#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{

    int n = 0;
    scanf("%d", &n);

    char *tszf = "~!@#$%^";
    char str[1024] = {0};
    

    for (size_t i = 0; i < n; i++)
    {
        int uppha = 0, lowpha = 0, ynum = 0, tsfhn = 0, count = 0;
        
        scanf("%s", str);
        
        if (strlen(str) >= 8 && strlen(str) < 16)
        {
            for (size_t z = 0; z < strlen(str); z++)
            {
                if (isupper(str[z]) != 0)
                    uppha++;
                else if (islower(str[z]) != 0)
                    lowpha++;
                else if (isdigit(str[z]) != 0)
                    ynum++;
                else if (strchr(tszf, str[z])!=NULL){
                    tsfhn++;
                }else
                    continue;
            }

            if (uppha > 0)
                count++;
            if (lowpha > 0)
                count++;
            if (ynum > 0)
                count++;
            if (tsfhn > 0)
                count++;

            if (count >= 3)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else
        {
            printf("NO");
        }

        memset(str, 0, strlen(str));
    }

    return 0;
}